class Grid(object):
    def __init__(self, xvalues, yvalues):
        if len(xvalues) != len(yvalues):
            raise RuntimeError('x and y values must be the same length')
        self.xvalues = xvalues
        self.yvalues = yvalues

    def __len__(self):
        return len(self.xvalues)

    def __setattr__(self, name, value):
        if name == 'xvalues' and 'yvalues' in vars(self) and len(self.yvalues) != len(value):
            raise RuntimeError('x and y values must be the same length')
        if name == 'yvalues' and 'xvalues' in vars(self) and len(self.xvalues) != len(value):
            raise RuntimeError('x and y values must be the same length')
        object.__setattr__(self, name, value)
